package individual.ircon.bilibili.ui;


import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.stage.Stage;

import java.io.IOException;
import java.util.List;

/**
 * 常用工具。
 */
public class Tools {
    private Tools(){}

    /**
     * 消息框。
     * @param type 类型
     * @param title 标题
     * @param message 消息
     */
    public static void alert(Alert.AlertType type, String title, String message) {
        Alert al = new Alert(type);
        al.setTitle(title);
        al.setContentText(message);
        al.show();
    }

    public static void showLotteryView(List<Shortlist> list, double hig, double wid) {
        // UI处理
        var loader = Lottery.getLoader();
        Parent ui = null;
        try {
            ui = loader.load();
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("UI加载失败", e);
        }

        Lottery lo = loader.getController();
        lo.addAll(list);

        Stage win = new Stage();
        win.setTitle("抽奖");
        win.setHeight(hig);
        win.setWidth(wid);
        win.setScene(new Scene(ui));


        win.showAndWait();
    }
}
